﻿function fun_dgv(json) {
    $('#order').bootstrapTable({
        data: json,
        columns: [
           { field: 'SiteId', title: '站点ID' },
           { field: 'AccountInfoId', title: '账号' },
           { field: 'AmazonOrderId', title: '订单号' },
           { field: 'OrderItemId', title: '订单项号' },
           { field: 'CurrencyCode', title: '币种' },
           { field: 'Amount', title: '订单金额' },
           { field: 'SellerSKU', title: 'Code' },
           { field: 'ASIN', title: 'ASIN' },
           { field: 'QuantityShipped', title: '数量' },
           { field: 'ItemPriceAmount', title: '单价' },
           {
               field: 'CreateTime', title: '时间', formatter: function (v, r, i) {
                   return jsonDateFormat(v, "yyyy-MM-dd hh:mm:ss");
               }
           }
        ]
    });
}

function jsonDateFormat(jsonDt, format) { 
    var date, timestamp, dtObj; 
    timestamp = jsonDt.replace(/\/Date\((\d+)\)\//, "$1"); 
    date = new Date(Number(timestamp)); 
    dtObj = {
        "M+": date.getMonth() + 1,   //月
        "d+": date.getDate(),        //日
        "h+": date.getHours(),       //时
        "m+": date.getMinutes(),     //分
        "s+": date.getSeconds(),     //秒
    }; 
    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
    } 
    for (var k in dtObj) { 
        if (new RegExp("(" + k + ")").test(format)) { 
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? dtObj[k] : ("00" + dtObj[k]).substr(("" + dtObj[k]).length));
        }
    } 
    return format;
}
